<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title></title>
    <link rel="stylesheet" href="/static/plugin/bootstrap/css/bootstrap.css">
    <link rel="stylesheet" href="/static/css/common.css">
    {% block head-js %}
{#        ckeditor会用到#}
    {% endblock %}
</head>
<body>

    <div id="myhead" style="height: 50px;background-color: #2459a2;margin: 0 auto;">
        <div id="mynav" style="width: 70%;height: 100%;margin: 0 auto;">

                <div class="container-fluid">
                <!-- Brand and toggle get grouped for better mobile display -->
                    <div class="navbar-header">
                        <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
                            <span class="sr-only">Toggle navigation</span>
                            <span class="icon-bar"></span>
                            <span class="icon-bar"></span>
                            <span class="icon-bar"></span>
                        </button>
                        <a class="navbar-brand" href="#"><img src="/static/img/logo.png"/></a>
                    </div>

                <!-- Collect the nav links, forms, and other content for toggling -->
                    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                        <ul class="nav navbar-nav" id="plate">
                            <li><a href="{% url 'index' %}">全部</a></li>
                            <li><a href="{% url 'plate' 1 %}">42区</a></li>
                            <li><a href="{% url 'plate' 2 %}">段子</a></li>
                            <li><a href="{% url 'plate' 3 %}">图片</a></li>
                            <li><a href="{% url 'plate' 4 %}">挨踢1024</a></li>
                            <li><a href="{% url 'plate' 5 %}">你问我答</a></li>
                            <li><a href="{% url 'webchat' %}">聊天室</a></li>
                        </ul>
                        <ul class="nav navbar-nav navbar-right" style="padding-right: 0;">
                            <!-- 如果用户已经登录，就显示用户名，否则显示一个注册登录的连接
                              显示nickname昵称而不是账户名，request中带有user，通过原生user表去反向查询关联的userinfo表的nicknmae字段-->
                              {% if request.user.is_authenticated %}
                                <li class="dropdown">
                                  <a class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false" style="color: white">
                                      {{ request.user.userinfo.nickname }}   {#显示登录的昵称#}
                                      <span class="caret"></span>
                                  </a>
                                  <ul class="dropdown-menu">
                                    <li><a href="#">修改密码</a></li>
                                    <li><a href="{% url 'logout' %}">注销</a></li>
                                  </ul>
                                </li>
                              {% else %}
                                <li><a style="color: white;" href="{% url 'register' %}">注册</a></li>
                                <li><a style="color: white;" href="{% url 'login' %}">登录</a></li>
                              {% endif %}

                            <form class="navbar-form navbar-left" role="search">
                                <div class="form-group">
                                    <input type="text" class="form-control" placeholder="Search">
                                </div>
                                <button type="submit" class="btn btn-default"><i class="glyphicon glyphicon-search"></i></button>
                            </form>
                        </ul>
                    </div><!-- /.navbar-collapse -->
                </div><!-- /.container-fluid -->

        </div>
    </div>
    <div id="mybody" style="width: 100%;height: 1800px;background-color: #DDDDDD;margin: 0 auto;">
        <div id="mycontain" style="width: 70%;height: 1800px;background-color: white;margin: 0 auto;">

                <div id="myleft" style="width: 70%;height: 1600px;float: left;padding: 5px;background-color: white;">
                    {% block page-left %}
                    <div id="left-head" style="min-height: 50px;margin-left: 30px;">
                        <div id="left-head-1" style="float: left;">
                        <ul class="nav nav-pills">
                          <li role="presentation" class="active"><a href="#">最热</a></li>
                          <li role="presentation"><a href="#">最新</a></li>
                          <li role="presentation"><a href="#">人类发布</a></li>
                        </ul>
                    </div>
                        <div id="left-head-2" style="float: right;">

                            <div class="container-fluid">
                                <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-2">
                                    <ul class="nav navbar-nav navbar-right">
                                        <li ><a style="color: #DDDDDD;" href="#">即时排序</a></li>
                                        <li><a style="color: #5cb85c;" href="#">24小时</a></li>
                                        <li><a style="color: #5cb85c;" href="#">3天</a></li>
                                        <li style="margin-top: 6px">
                                            <button type="button" style="background-color: #5cb85c;color: white;" class="btn btn-default">
                                                <a href="{% url 'publish' %}" >&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp+发&nbsp&nbsp布&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp</a>
                                            </button>
                                        </li>
                                    </ul>
                                </div>
                            </div>

                    </div>
                    </div >

                    <div id="left-alert" style="margin-left: 30px;text-align: center;" class="alert alert-warning" role="alert">
                        <a style="cursor: pointer;">13条入热榜，点击查看</a>
                    </div>

                        <!-- 左边的内容，一个文章占一个div
                         一个文章里，左边是标题等文字，右边是图片,占比同样是用col-md-x;
                         文章后发布的在上面，reversed  -->
                    {% for article in articles reversed %}
                    <div style="margin-top: 10px;margin-left: 30px;min-height: 10px;">
                        <div class="media row">
                            <div class="media-left col-md-9">
                                <div class="media-heading">
                                    <a href="{% url 'article' article.id %}" style="color: #369;font-size: 14px;font-weight: bold;">
                                    {{ article.title }}
                                    </a>
                                    <span style="color: #b4b4b4;margin-left: 20px">{{ article.plate }}</span>
                                </div>
                                <div style="height: 20px;margin: 10px 10px 0 20px;">
                                    <!--  models反向查询：通过谁关联我的表，可以取到table_set的一个集合
                                             再通过select_related，将集合变成一个列表，计算数量；-->
                                    <a href="#" >
                                        <i class="glyphicon glyphicon-thumbs-up"></i>
                                        <span class="badge">{{ article.thumbup_set.select_related.count }}</span>
                                    </a>
                                    <a href="#" style="padding-left: 30px">
                                        <i class="glyphicon glyphicon-edit"></i>
                                        <span class="badge">{{ article.comment_set.select_related.count }}</span>
                                    </a>
                                    <a href="#" style="padding-left: 30px">
                                        <i class="glyphicon glyphicon-heart"></i>
                                        <span class="badge">收藏</span>
                                    </a>
                                    <a href="#" style="padding-left: 30px">
                                        <i class="glyphicon glyphicon-user"></i>
                                        <a style="color: #31b0d5">{{ article.author }}</a>
                                    </a>
                                    <a href="#" style="padding-left: 30px;color: orange">{{ article.publish_date }}</a>
{#                                    <span style="color: #ddd">入热门榜</span>#}
                                </div>
                                <div class="media-sumary" style="padding: 15px;">
                                    <a href="#" ></a>
                                    <span style="color: #b4b4b4;">{{ article.summary }}</span>
                                </div>
                            </div>
                            <div class="media-right col-md-3">
                                <a href="{% url 'article' article.id %}"  >
                                    <img data-holder-rendered="true" src="{{ article.img }}" style="width: 150px; height: 100px;" class="media-object">
                                </a>
                            </div>
                        </div>
                        <hr/>
                    </div>
                    {% endfor %}

                    <div id="left-bottom" style="margin-left: 275px;">
                        <nav>
                            <ul class="pagination">
                                <li>
                                    <a href="#" aria-label="Previous">
                                        <span aria-hidden="true">&laquo;</span>
                                    </a>
                                </li>
                                <li class="active"><a href="#">1<span class="sr-only">(current)</span></a></li>
                                <li><a href="#">2</a></li>
                                <li><a href="#">3</a></li>
                                <li><a href="#">4</a></li>
                                <li><a href="#">5</a></li>
                                <li>
                                    <a href="#" aria-label="Next">
                                        <span aria-hidden="true">&raquo;</span>
                                    </a>
                                </li>
                            </ul>
                        </nav>
                    </div>
                    {% endblock %}
                </div>

            <div id="myright" style="width: 30%;height: 1600px;float:left;padding: 5px;background-color: white;">
                {% block page-right %}
                <div id="right-chat" style="margin: 20px;">
                    <div class="widget-content padded" style="border: 1px solid #ddd;">
                        <ul>
                            <li class="current-user">
                                <div class="bubble">
                                    <a class="user-name" href="#">王晓</a>
                                    <p class="message">我们根本无法确定哪一个才是今生最爱，如果不懂得去珍惜，你身边这个爱你的/你爱的人，在某一天，也会成为你身边的过客。</p>
                                    <p class="time"><strong>今天 </strong>3:53 pm</p>
                                </div>
                            </li>
                            <li class="current-user">
                                <div class="bubble">
                                    <a class="user-name" href="#">王晓</a>
                                    <p class="message">爱与不爱，无非也就是在一念之间。</p>
                                    <p class="time"><strong>今天 </strong>3:53 pm</p>
                                </div>
                            </li>
                            <li class="current-user">
                                <div class="bubble">
                                    <a class="user-name" href="#">王晓</a>
                                    <p class="message">珍惜当前，永远胜于三心二意。</p>
                                    <p class="time"><strong>今天 </strong>3:53 pm</p>
                                </div>
                            </li>
                            <li class="current-user">
                                <div class="bubble">
                                    <a class="user-name" href="#">王晓</a>
                                    <p class="message">
                                        &gt;&gt;&gt;阅读《婚恋潜规则》&lt;&lt;&lt;
                                    </p>
                                    <p class="time">
                                        <strong>今天 </strong>3:53 pm
                                    </p>
                                </div>
                            </li>
                            <li>
                                <div class="bubble">
                                    <a class="user-name" href="#">兰若</a>
                                    <p class="message">
                                        柯云路作品出版联络信箱：keyunlu@vip.sina.com
                                    </p>
                                    <p class="time">
                                        <strong>今天 </strong>3:53 pm
                                    </p>
                                </div>
                            </li>
                        </ul>
                    </div>
                    <div class="post-message">
                        <input class="form-control" placeholder="输入需要发送的信息…" type="text" >
                        <input value="发送" type="submit" class="pull-right">
                    </div>
                </div>
                <div id="right-account" style="margin: 20px;">
                    <a href="#">
                        <i class="glyphicon glyphicon-lock" style="color: #369;font-size: 18px;">如何避免自己被封号</i>
                    </a>
                </div>
                {% endblock %}
                <div id="right-download" style="margin: 20px;">
                    <a href="http://dig.chouti.com/download/model"><img src="/static/img/download.png" class="img-responsive"></a>
                </div>
                <div id="right-hot" style="margin: 20px;">
                    <div style="font-size: 18px;font-weight: bold;">
                        <span>24小时全部</span>
                        <span style="color: red">TOP 10</span>
                    </div>
                    <!-- 选项卡组件（菜单项nav-tabs）-->
                    <ul id="myTab" class="nav nav-tabs" role="tablist">
                        <li class="active" style="width: 50%;"><a href="#click" role="tab" data-toggle="tab">最热榜</a></li>
                        <li style="width: 50%;"><a href="#comment" role="tab" data-toggle="tab">最热评论</a></li>
                    </ul>
                    <!-- 选项卡面板 -->
                    <div id="myTabContent" class="tab-content">
                        <div class="tab-pane active" id="click">
                            <a href="#"><img src="/static/img/hotTab.png" class="img-responsive"></a>
                        </div>
                        <div class="tab-pane" id="comment">
                            <a href="#"><img src="/static/img/hotComment.png" class="img-responsive"></a>
                        </div>
                    </div>
                </div>
            </div>
            <div id="mybottom" style="width: 100%;height: 200px;margin: 0 auto;padding: 0 28px;clear: both;">
                <div style="padding-top: 15px;text-align: center;border-top: 1px solid #ccdcef;position: relative;">
                    <a style="color: black;">关于我们</a>
                    <span>|</span>
                    <a style="color: black;">联系我们</a>
                    <span>|</span>
                    <a style="color: black;">服务条款</a>
                    <span>|</span>
                    <a style="color: black;">隐私政策</a>
                    <span>|</span>
                    <a style="color: black;">抽屉新热榜工具</a>
                    <span>|</span>
                    <a style="color: black;">下载客户端</a>
                    <span>|</span>
                    <a style="color: black;">意见与反馈</a>
                    <span>|</span>
                    <a style="color: black;">友情链接</a>
                    <span>|</span>
                    <a href="http://www.shouye.com/Index.do?method=show&amp;pageId=44251&amp;jid=xinrebang@gozap.com" style="color: black;" >公告</a>
                </div>
                <div class="foot-nav2" style="padding-top: 15px;text-align: center;position: relative;">
                    <span class="foot_d">旗下站点</span>
                    <span class="foot_a">© 2016 cccttt.com</span>
                    <a target="_blank" href="http://www.miibeian.gov.cn/" class="foot_b">京ICP备12345678号-3 京公网安备 110123456789</a>
                    <div style="margin-top:6px;">版权所有：北京ggg科技有限公司</div>
                </div>
            </div>
        </div>
    </div>

    <script src="/static/js/jquery-2.1.4.min.js"></script>
    <script src="/static/plugin/bootstrap/js/bootstrap.min.js"></script>

    <script src="/static/js/jquery.goup.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $(function(){
                /*
                $('#navbar li').click(founction(){
                    $(this).addClass('active');
                    $(this).siblings().removeClass('active');
                });
                如果按照上面的这种方法，在index页面click跳转到其它页面，它只在index页面中标签点亮了，
                跳转之后，页面刷新，又显示了母版的active标签，被click的标签还是没有active的class；
                所以，要在当前页面，即当前页面框架加载完成，根据用户请求url路径，找到此标签，加入active样式；
                注意：在js中调用templatetags变量，要加引号；如果不确定输出格式，可以在浏览器的console中尝试。
                > $("#navbar a[href='/plate/1/']")
                < [<a href=​"/plate/​1/​">42区​</a>​]
                综合区index也在urls里设置一个name='index'别名，也可以符合模板语言了{% url 'index' %}，当然用‘/’也可以；
                */
                var menus = $("#plate a[href='{{ request.path }}']")[0];
                $(menus).parent().addClass('active-blue');
                $(menus).parent().siblings().removeClass('active-blue');
            });
            $.goup({    /* 回到顶部，jquery插件goup；*/
                trigger: 50,
                bottomOffset: 50,
                locationOffset: 100,
                title: 'GO TOP',
                titleAsText: true
            });

        });
{#        {% block bottom-js %}#}
{#        {% endblock %}#}
    </script>
{% block bottom-js %}
{% endblock %}
</body>
</html>